
/****** Object:  StoredProcedure [dbo].[GetUpComingMatches]    Script Date: 12/8/2014 9:15:38 PM ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
-- =============================================  
-- Author:  <Author,,Name>  
-- Create date: <Create Date,,>  
-- Description: <Description,,>  
-- =============================================  
ALTER PROCEDURE [dbo].[GetUpComingMatches]  
 -- Add the parameters for the stored procedure here  
   
AS  
BEGIN  
 -- SET NOCOUNT ON added to prevent extra result sets from  
 -- interfering with SELECT statements.  
 SET NOCOUNT ON;  
    -- Insert statements for procedure here  
   
 Select ms.Id, t.TeamName as Team1 ,t1.TeamName as Team2, Cast(Date as date) as Date, Time from MatchSchedule ms  
 INNER JOIN Team t on ms.Team1 = t.Id  
 INNER JOIN Team t1 on ms.Team2 = t1.Id  
 WHERE ms.IsActive = 1 and ms.IsDeleted = 0  and CAST(ms.Date as DATE) <= CAST(GETUTCDATE() as  DATE)
 AND ms.Id NOT IN (Select MatchScheduleId from Result)
   
END
